import 'package:flutter/material.dart';
import 'package:hotpot/route/route_ext.dart';
import 'package:hotpot/widgets/widget_ext.dart';

class SimpleDialog extends StatefulWidget {
  final String title;
  final String content;
  final String leftText;
  final void Function()? onLeftTap;
  final String rightText;
  final void Function()? onRightTop;

  const SimpleDialog({
    super.key,
    this.title = 'Tip',
    this.content = '',
    this.rightText = 'Ok',
    this.onLeftTap,
    this.leftText = 'Cancel',
    this.onRightTop,
  });

  @override
  State<SimpleDialog> createState() => _SimpleDialogState();
}

class _SimpleDialogState extends State<SimpleDialog> {
  @override
  Widget build(BuildContext context) {
    return Dialog(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          widget.title.text(size: 16, bold: true, color: Colors.black),
          10.hSizedBox,
          widget.content.text(size: 14, color: Colors.black, maxLines: 10).paddingOnly(left: 10, right: 10),
          10.hSizedBox,
          Row(
            children: [
              item(widget.leftText, widget.onLeftTap ?? pop),
              item(widget.rightText, widget.onRightTop ?? pop),
            ],
          ),
        ],
      ).sizedBox(width: 200),
    );
  }

  item(String text, void Function()? onTap) {
    return text.text().paddingSymmetric(vertical: 10).alignCenter().gestureDetector(onTap: onTap).expanded();
  }
}
